package com.example.mydy.model;

import java.io.Serializable;
import java.util.Date;

/**
 * 项目模型类
 */
public class Project implements Serializable {
    private int id;
    private String title;
    private String description;
    private double reward;
    private String imageUrl;
    private Date createdAt;
    private String status; // 项目状态：可申请、进行中、已完成
    private int creatorId; // 创建者ID
    private String article; // 项目文章内容
    private double price;
    private boolean isHot;
    private boolean isNew;
    private String createTime;
    private int unlockedCount;
    
    // 状态常量
    public static final String STATUS_OPEN = "open";
    public static final String STATUS_IN_PROGRESS = "in_progress";
    public static final String STATUS_COMPLETED = "completed";
    public static final String STATUS_CANCELLED = "cancelled";
    public static final String STATUS_PLANNED = "planned";
    public static final String STATUS_ACTIVE = "active";
    public static final String STATUS_INACTIVE = "inactive";
    
    public Project() {
    }

    public Project(int id, String title, String description, double reward, String imageUrl, Date createdAt, String status, int creatorId) {
        this.id = id;
        this.title = title;
        this.description = description;
        this.reward = reward;
        this.imageUrl = imageUrl;
        this.createdAt = createdAt;
        this.status = status;
        this.creatorId = creatorId;
    }
    
    public Project(int id, String title, String description, double reward, String imageUrl, Date createdAt, String status, int creatorId, String article) {
        this.id = id;
        this.title = title;
        this.description = description;
        this.reward = reward;
        this.imageUrl = imageUrl;
        this.createdAt = createdAt;
        this.status = status;
        this.creatorId = creatorId;
        this.article = article;
    }
    
    public Project(int id, String title, String description, String imageUrl, double price) {
        this.id = id;
        this.title = title;
        this.description = description;
        this.imageUrl = imageUrl;
        this.price = price;
        this.isHot = false;
        this.isNew = false;
        this.unlockedCount = 0;
    }
    
    public Project(int id, String title, String description, String imageUrl, double price, boolean isHot, boolean isNew) {
        this.id = id;
        this.title = title;
        this.description = description;
        this.imageUrl = imageUrl;
        this.price = price;
        this.isHot = isHot;
        this.isNew = isNew;
        this.unlockedCount = 0;
    }
    
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    /**
     * 获取项目名称，作为getTitle的别名
     * @return 项目标题
     */
    public String getName() {
        return title;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public double getReward() {
        return reward;
    }
    
    public void setReward(double reward) {
        this.reward = reward;
    }
    
    public String getImageUrl() {
        return imageUrl;
    }
    
    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }
    
    public Date getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public int getCreatorId() {
        return creatorId;
    }
    
    public void setCreatorId(int creatorId) {
        this.creatorId = creatorId;
    }
    
    public String getArticle() {
        return article;
    }
    
    public void setArticle(String article) {
        this.article = article;
    }
    
    public double getPrice() {
        return price;
    }
    
    public void setPrice(double price) {
        this.price = price;
    }
    
    public boolean isHot() {
        return isHot;
    }
    
    public void setHot(boolean hot) {
        isHot = hot;
    }
    
    public boolean isNew() {
        return isNew;
    }
    
    public void setNew(boolean aNew) {
        isNew = aNew;
    }
    
    public String getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    
    public int getUnlockedCount() {
        return unlockedCount;
    }
    
    public void setUnlockedCount(int unlockedCount) {
        this.unlockedCount = unlockedCount;
    }
    
    // 辅助方法，检查项目是否可以申请
    public boolean isOpen() {
        return STATUS_OPEN.equals(status);
    }
    
    // 辅助方法，检查项目是否进行中
    public boolean isInProgress() {
        return STATUS_IN_PROGRESS.equals(status);
    }
    
    // 辅助方法，检查项目是否已完成
    public boolean isCompleted() {
        return STATUS_COMPLETED.equals(status);
    }
    
    // 辅助方法，检查项目是否已取消
    public boolean isCancelled() {
        return STATUS_CANCELLED.equals(status);
    }
    
    // 辅助方法，检查项目是否处于计划中
    public boolean isPlanned() {
        return STATUS_PLANNED.equals(status);
    }

    @Override
    public String toString() {
        return "Project{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", price=" + price +
                ", isHot=" + isHot +
                ", isNew=" + isNew +
                '}';
    }
} 